{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "import pencil as pc\n",
    "import os"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# Deleting Runs\n",
    "\n",
    "This is based on tutorial 0002.\n",
    "\n",
    "Now, lets get rid of the simulation we created beforehand. Therefor, we use 'pcn.get_sims(folder)' to get all simulations that are within a folder! This is very mighty, as you will see in the following. Since deleting should always considered seriously, we first do a dry removal run first.\n",
    "\n",
    "## Dry Deleting, nothing will happen here"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "root_path = '../tmp/0002'\n",
    "\n",
    "SIMS = pc.get_sims(root_path)\n",
    "for SIM in SIMS:\n",
    "    print('! Removing '+SIM.name)\n",
    "    SIM.remove()\n",
    "    print('\\n')"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Now do the real deleting"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "SIMS = pc.get_sims(root_path)\n",
    "for SIM in SIMS:\n",
    "    print('! Removing '+SIM.name)\n",
    "    SIM.remove(do_it=True, do_it_really=True, remove_data=True)\n",
    "    print('\\n')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "os.listdir(root_path)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "See its empty!"
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.6.9"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 1
}
